home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club (Business) 1997 July / Software of the Month Club - Business (Volume 239) (July 1997).iso / pc / code / shared.dxr / 04468_Initializations.ls < prev    next >
Encoding:
Text File  |  1996-02-21  |  8.3 KB  |  218 lines

  1. global gObjectsA, gObjectsB, gObjectsC, gObjectsD, gObjectsE, gObjectsF, gObjectsG, gObjectsH, gWorld, gStates, gOBJECTS, gHotRects, gScreenState, gCursorList, gTimerList, gHitMaps, gPuppetlines, gKeyRef, cNullCast, cNullQTmovie, NULLRECT, gSpritePropTypes, gQTproplist, cNUllCharmovie, sPICTSPRITE, sQTSPRITE, sCURSORSPRITE, sCPSprite, sQTCharSprite, gUnvObjects, void, gAngles, gLastCursor, gPlayingQT, gCursorPresent, gScreenWidth, gScreenHeight, gCurKeyList, gTransMovieName, gAnimationObjects, gDeathRow, gLastKeyList, gKeyFrameSound, gEnvironmentSound, gKeyFrameSoundMode, gKeyExitSound, gHaveNavs, gNextEnvLetter, gNextDIRFile, gMIDIPlayTRUE, gInitalized, noteObjs, windowsMIDIXObj, xNAVXOBJ, xCURXOBJ, gCPU, gfileSep, gRootPath, gHDpath, gXobjs, gXOBJPath, gGlobal, gCDpath, gCDName, gSoundChannels, gsoundLevel, savedFilesPath, miscXobj, gCodePath, IOerrors, gNoPreLoadRefNames, gLimitPreLoad, gdirtyGame
  2.  
  3. on BuildDisc
  4.   StoreObjectWorlds()
  5. end
  6.  
  7. on reBuild
  8.   OneTimeInitalizations(#true)
  9. end
  10.  
  11. on StartUpInitalizations
  12.   if voidp(gfileSep) then
  13.     setUpIndevelopment()
  14.   end if
  15.   InitXOBJs()
  16.   InitglobalConstants()
  17.   InitSystemVars()
  18. end
  19.  
  20. on OneTimeInitalizations Build
  21.   InitgWorlds()
  22.   InitgObjects()
  23.   initAmbientSound()
  24.   initAnimEngine()
  25.   initNoPreLoadList()
  26.   if Build = #true then
  27.     InitUnCompiledOBJs()
  28.   end if
  29.   InittheTimer()
  30.   set gInitalized to #true
  31.   set letter to value("#" & char 1 of the movieName)
  32.   set gKeyRef to getaProp(getaProp(gStates, #EnviroLOC), letter)
  33.   set gLastKeyList to getaProp(gWorld, #trans)
  34.   set gCurKeyList to getaProp(gWorld, gKeyRef)
  35. end
  36.  
  37. on initNoPreLoadList
  38.   if gLimitPreLoad = 1 then
  39.     set gNoPreLoadRefNames to value(field "noPreLoadList")
  40.     sort(gNoPreLoadRefNames)
  41.   else
  42.     set gNoPreLoadRefNames to []
  43.   end if
  44. end
  45.  
  46. on setUpIndevelopment
  47.   if the machineType = 256 then
  48.     set gCPU to #mpc
  49.     set gfileSep to "\"
  50.   else
  51.     set cpu to #MAC
  52.     set gfileSep to ":"
  53.     set gCDpath to "Chaos:"
  54.   end if
  55.   set gCodePath to string(gCDpath & "CODE" & gfileSep)
  56. end
  57.  
  58. on InitgWorlds
  59.   RebuildgWorld()
  60. end
  61.  
  62. on InitgObjects
  63.   RebuildgOBjects(15)
  64.   InitgStates()
  65. end
  66.  
  67. on InitglobalConstants
  68.   set gMIDIPlayTRUE to #false
  69.   set gPuppetlines to [#objects: []]
  70.   sort(gPuppetlines)
  71.   set gHaveNavs to #true
  72.   set gCursorPresent to #false
  73.   set gHitMaps to [:]
  74.   sort(gHitMaps)
  75.   set gHotRects to [:]
  76.   sort(gHotRects)
  77.   set gLastKeyList to [:]
  78.   set gScreenState to [:]
  79.   sort(gScreenState)
  80.   set gSoundChannels to [:]
  81.   sort(gSoundChannels)
  82.   set gGlobal to 0
  83.   set gsoundLevel to the soundLevel
  84.   set gWorld to [:]
  85.   sort(gWorld)
  86.   set NULLRECT to rect(0, 0, 0, 0)
  87.   set gScreenWidth to 560
  88.   set gScreenHeight to 336
  89.   InitCursorOBJ()
  90.   set sPICTSPRITE to 1
  91.   set sQTCharSprite to 36
  92.   set sCPSprite to 46
  93.   set sCURSORSPRITE to 47
  94.   set sQTSPRITE to 48
  95.   set cNullCast to the number of cast "cNullSprite"
  96.   set cNullQTmovie to the number of cast "QTPlaceholder"
  97.   set cNUllCharmovie to the number of cast "QTCharPlaceHolder"
  98.   if voidp(gLimitPreLoad) then
  99.     set gLimitPreLoad to 0
  100.   end if
  101.   set gdirtyGame to 0
  102.   InitDefaultSpriteProp()
  103.   initdefaultQTProp()
  104.   set gUnvObjects to [#PDAObj, #TubeObj, #Leaf2Obj, #Leaf1Obj, #BagObj, #SeedObj, #MapObj, #CDObj, #SaveOBj, #Volumeobj, #syrnObj]
  105.   InitgStates()
  106. end
  107.  
  108. on InitgStates
  109.   set DynamicStates to []
  110.   sort(DynamicStates)
  111.   set BeenThere to [:]
  112.   sort(BeenThere)
  113.   set gStates to [#EnviroLetter: #empty, #Credits: -37, #Debt: 10075, #EnviroLOC: [#A: #A03, #B: #B01, #C: #C01, #D: #D04, #E: #E01, #F: #F01, #G: #G03, #H: #H01], #BeenThere: BeenThere, #Dynamic: DynamicStates, #Conditions: [#Trailer: 0, #WeatherControl: 0, #Weather: 0, #Instruments: 0, #radioStation: 0, #Coast: 0, #forest: 0, #shortStock: 0, #Defibrillate: 0, #JenkinsLeaf: 0, #Microscope: 0, #Heart: 0, #longStock: 0], #gCurrentGameName: #virgin]
  114.   sort(gStates)
  115. end
  116.  
  117. on InitDefaultSpriteProp
  118.   set gSpritePropTypes to [#type: [#script: "the type of sprite", #DeFault: 1], #backcolor: [#script: "the Backcolor of sprite", #DeFault: 0], #forecolor: [#script: "the ForeColor of sprite", #DeFault: 255], #trails: [#script: "the trails of sprite", #DeFault: 0], #stretch: [#script: "the stretch of sprite", #DeFault: 0], #ink: [#script: "the ink of sprite", #DeFault: 36], #blend: [#script: "the blend of sprite", #DeFault: 100], #rect: [#script: "the rect of sprite", #DeFault: rect(0, 0, 0, 0)], #visible: [#script: "the visible of sprite", #DeFault: 1]]
  119.   sort(gSpritePropTypes)
  120. end
  121.  
  122. on initdefaultQTProp
  123.   set QTSprite to sQTCharSprite
  124.   set QTcast to cNUllCharmovie
  125.   set gQTproplist to [#center: [#script: "the center of cast", #CastSprite: QTSprite, #DeFault: 0], #controller: [#script: "the controller of cast", #CastSprite: QTcast, #DeFault: 0], #crop: [#script: "the crop of cast", #CastSprite: QTcast, #DeFault: 0], #directToStage: [#script: "the directToStage of cast", #CastSprite: QTcast, #DeFault: 1], #loop: [#script: "the loop of cast", #CastSprite: QTcast, #DeFault: 0], #pausedAtStart: [#script: "the pausedAtStart of cast", #CastSprite: QTcast, #DeFault: 0], #volume: [#script: "the volume of sprite", #CastSprite: QTSprite, #DeFault: 255], #movieTime: [#script: "the movieTime of sprite", #CastSprite: QTSprite, #DeFault: 0], #movieRate: [#script: "the movieRate of sprite", #CastSprite: QTSprite, #DeFault: 0], #preLoad: [#script: "the preLoad of cast", #CastSprite: QTcast, #DeFault: 0], #sound: [#script: "the sound of cast", #CastSprite: QTcast, #DeFault: 1], #video: [#script: "the video of cast", #CastSprite: QTcast, #DeFault: 1], #startTime: [#script: "the startTime of sprite", #CastSprite: QTSprite, #DeFault: 0], #stopTime: [#script: "the stopTime of sprite", #CastSprite: QTSprite, #DeFault: 0]]
  126.   sort(gQTproplist)
  127. end
  128.  
  129. on initAnimEngine
  130.   if not voidp(gAnimationObjects) then
  131.     repeat with obj in gAnimationObjects
  132.       death(obj)
  133.     end repeat
  134.   end if
  135.   set gAnimationObjects to [:]
  136.   sort(gAnimationObjects)
  137.   set gDeathRow to []
  138. end
  139.  
  140. on InitCursorOBJ
  141.   set gLastCursor to 4548
  142.   set gCursorList to [#NAV: [[4550, 4551], [4552, 4553], [4554, 4555], [4556, 4557], [4558, 4559], [4560, 4561], [4562, 4563], [4564, 4565], [4548, 4549]], #Pointer: [4535, 4536], #Grab: [4537, 4538], #NullCursor: [4548, 4549], #Hand: [4539, 4540], #Mnote: [4542, 4543]]
  143. end
  144.  
  145. on InitSystemVars
  146.   set IOerrors to [33: "File directory full", 34: "Volume full", 35: "Volume not found", 36: "I/O Error", 37: "Bad file name", 38: "File not open", 42: "Too many files open", 43: "File not found", 48: "Can not write file over an existing folder", 49: "File open with write permission", 56: "No such drive", 65: "No disk in drive", 120: "Directory not found"]
  147.   if gCPU = #mpc then
  148.     set extension to ".dll"
  149.   else
  150.     set extension to EMPTY
  151.   end if
  152.   set miscXobj to Misc_X(mnew)
  153.   if gCPU = #MAC then
  154.     set savedFilesPath to miscXobj(mSystemFolder) & "Preferences:Chaos"
  155.   else
  156.     set savedFilesPath to miscXobj(mWindowsDirectory) & "Chaos"
  157.   end if
  158.   set savedPathExist to miscXobj(mFolderExists, savedFilesPath)
  159.   if not savedPathExist then
  160.     set theResult to miscXobj(mInsureFolder, savedFilesPath & gfileSep)
  161.     if theResult <> 0 then
  162.       displayChaosError(#severe, "Problem creating Saved Files folder" && savedFilesPath)
  163.     end if
  164.   end if
  165. end
  166.  
  167. on savedGamesExist
  168.   set nameList to savedGameNames()
  169.   if count(nameList) > 0 then
  170.     return 1
  171.   else
  172.     setaProp(gStates, #gCurrentGameName, #virgin)
  173.     return 0
  174.   end if
  175. end
  176.  
  177. on savedGameNames
  178.   if voidp(savedFilesPath) then
  179.     InitSystemVars()
  180.   end if
  181.   set theNames to []
  182.   if gCPU = #MAC then
  183.     repeat with fileNumber = 1 to the maxinteger
  184.       set theFileName to getNthFileNameInFolder(savedFilesPath, fileNumber)
  185.       if theFileName <> EMPTY then
  186.         add(theNames, getNthFileNameInFolder(savedFilesPath, fileNumber))
  187.         next repeat
  188.       end if
  189.       exit repeat
  190.     end repeat
  191.   else
  192.     repeat with fileNumber = 1 to the maxinteger
  193.       set theFileName to getNthFileNameInFolder(savedFilesPath, fileNumber)
  194.       if (theFileName <> EMPTY) and (theFileName contains saveDataType()) then
  195.         add(theNames, getNthFileNameInFolder(savedFilesPath, fileNumber))
  196.         next repeat
  197.       end if
  198.       if theFileName = EMPTY then
  199.         exit repeat
  200.       end if
  201.     end repeat
  202.   end if
  203.   sort(theNames)
  204.   return theNames
  205. end
  206.  
  207. on initAmbientSound
  208.   set gKeyFrameSound to #noEnter
  209.   set gEnvironmentSound to #empty
  210.   set gKeyFrameSoundMode to #KFSOUND
  211.   setSoundVolumes()
  212. end
  213.  
  214. on ResetGlobals
  215.   CloseUniversalXOBJs()
  216.   clearGlobals()
  217. end
  218.